﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SilverlightApplication3
{
    /// <summary>
    /// 
    /// </summary>
	public partial class MainPage : UserControl
	{
		public MainPage()
		{
			// Required to initialize variables
			InitializeComponent();
            Current = DateTime.Today;
            active.Text = Current.ToString("MMMM");
		}

        public DateTime Current { get; set; }

        private DateTime GetNextMonth()
        {
            return Current.AddMonths(1);
        }

        private DateTime GetPrevMonth()
        {
            return Current.AddMonths(-1);
        }

		private void nextArrow_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
		{           

            TextBlock active = new TextBlock();
            active.Height = 40;
            active.Width = 175;
            active.TextAlignment = TextAlignment.Center;
            active.RenderTransform = new CompositeTransform();
            active.Margin = new Thickness(23, 27, 24, 0);            
            active.HorizontalAlignment = HorizontalAlignment.Left;
            active.VerticalAlignment = VerticalAlignment.Top;
            active.FontSize = 32;
            active.Name = "active";
            active.Text = Current.ToString("MMMM");
            
            TextBlock next = new TextBlock();
            next.Height = 40;
            next.Width = 175;
            next.TextAlignment = TextAlignment.Center;
            next.Opacity = 0;
            next.RenderTransform = new CompositeTransform(); ;
            next.Margin = new Thickness(0, 27, -178, 0);            
            next.HorizontalAlignment = HorizontalAlignment.Right;
            next.VerticalAlignment = VerticalAlignment.Top;
            next.FontSize = 32; next.Name = "next";
            next.Text = GetNextMonth().ToString("MMMM");

            TextBlock previous = new TextBlock();
            previous.Height = 40;
            previous.Width = 175;
            previous.TextAlignment = TextAlignment.Center;
            previous.Opacity = 0;
            previous.RenderTransform = new CompositeTransform();
            previous.Margin = new Thickness(-179, 27, 0, 0);
            previous.HorizontalAlignment = HorizontalAlignment.Left;
            previous.VerticalAlignment = VerticalAlignment.Top;
            previous.FontSize = 32; previous.Name = "previous";
            previous.Text = GetPrevMonth().ToString("MMMM");

            

            Current = GetNextMonth();

            LayoutRoot.Children.Clear();
            LayoutRoot.Children.Add(active);
            LayoutRoot.Children.Add(previous);
            LayoutRoot.Children.Add(next);
            LayoutRoot.Children.Add(nextArrow);
            LayoutRoot.Children.Add(PrevArrow);

            ((Storyboard)this.Resources["NextAnimation"]).Begin();
		}

               

		private void PrevArrow_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
		{
            TextBlock active = new TextBlock();
            active.Height = 40;
            active.Width = 175;
            active.TextAlignment = TextAlignment.Center;
            active.RenderTransform = new CompositeTransform();
            active.Margin = new Thickness(23, 27, 24, 0);
            active.HorizontalAlignment = HorizontalAlignment.Left;
            active.VerticalAlignment = VerticalAlignment.Top;
            active.FontSize = 32;
            active.Name = "active";
            active.Text = Current.ToString("MMMM");

            TextBlock next = new TextBlock();
            next.Height = 40;
            next.Width = 175;
            next.TextAlignment = TextAlignment.Center;
            next.Opacity = 0;
            next.RenderTransform = new CompositeTransform();
            next.Margin = new Thickness(0, 27, -178, 0);
            next.HorizontalAlignment = HorizontalAlignment.Right;
            next.VerticalAlignment = VerticalAlignment.Top;
            next.FontSize = 32; next.Name = "next";
            next.Text = GetNextMonth().ToString("MMMM");

            TextBlock previous = new TextBlock();
            previous.Height = 40;
            previous.Width = 175;
            previous.TextAlignment = TextAlignment.Center;
            previous.Opacity = 0;
            previous.RenderTransform = new CompositeTransform();
            previous.Margin = new Thickness(-179, 27, 0, 0);
            previous.HorizontalAlignment = HorizontalAlignment.Left;
            previous.VerticalAlignment = VerticalAlignment.Top;
            previous.FontSize = 32; previous.Name = "previous";
            previous.Text = GetPrevMonth().ToString("MMMM");


            Current = GetPrevMonth();

            LayoutRoot.Children.Clear();
            LayoutRoot.Children.Add(active);
            LayoutRoot.Children.Add(previous);
            LayoutRoot.Children.Add(next);
            LayoutRoot.Children.Add(nextArrow);
            LayoutRoot.Children.Add(PrevArrow);

            ((Storyboard)this.Resources["PrevAnimation"]).Begin();
		}

        
	}
}